package com.example.a1.fannong.ui.shoppingcart;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.example.a1.fannong.R;
import com.example.a1.fannong.adapter.AddressAapter;
import com.example.a1.fannong.core.app.BaseActivity;
import com.example.a1.fannong.model.AddressEntity;
import com.example.a1.fannong.view.MyActionBar;

import java.util.ArrayList;
import java.util.List;

import cn.personal.library.view.listview.PullRefreshView;
import cn.personal.library.viewinject.FindViewById;
import cn.personal.library.viewinject.OnClick;
import cn.personal.library.viewinject.ViewInjecter;

public class SelectAddressActivity extends BaseActivity {

    @FindViewById(R.id.address_list)
    private PullRefreshView pullRefreshView;
    @FindViewById(R.id.top_bar)
    private MyActionBar myActionBar;
    @FindViewById(R.id.newaddress_bt)
    private Button mNewAddressTv;

    private AddressAapter addressAapter;

    private List<AddressEntity> addressEntities;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_select_address);
        ViewInjecter.inject(this);
        initData();
        addressAapter = new AddressAapter(getContext());
        pullRefreshView.setAdapter(addressAapter);
        addressAapter.changeItems(addressEntities);
    }

    private void initData(){
       addressEntities = new ArrayList<>();
        for (int i = 0;i<5 ;i++){
            addressEntities.add(new AddressEntity(i+"","姓名"+i,"地址"+i ,"详细地址"+i ,"1835555411"+i,false));
        }
    }

    @OnClick({R.id.newaddress_bt})
    public void onItemClick(View view) {
        switch (view.getId()) {
            case R.id.newaddress_bt:
                AddressActivity.startActivity(this,"0");
                break;
        }
    }
    public static void startActivity(Context context) {
        Intent intent = new Intent(context, SelectAddressActivity.class);
        context.startActivity(intent);
    }

}
